package com.ruoyi.workbench.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.workbench.domain.WorkMatter;
import com.ruoyi.workbench.domain.WorkTask;
import com.ruoyi.workbench.domain.WorkUserMatter;
import com.ruoyi.workbench.service.IWorkTaskService;
import com.ruoyi.workbench.service.IWorkUserMatterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 用户收藏事项Controller
 * 
 * @author Guojl
 * @date 2024-07-06
 */
@RestController
@RequestMapping("/care/care")
public class WorkUserMatterController extends BaseController
{
    @Autowired
    private IWorkUserMatterService workUserMatterService;

    /**
     * 查询用户收藏事项列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WorkUserMatter workUserMatter)
    {
        startPage();
        List<WorkMatter> list = workUserMatterService.getList(workUserMatter);
        return getDataTable(list);
    }

    /**
     * 新增用户收藏事项
     */
    @Log(title = "用户收藏事项", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody WorkUserMatter workUserMatter)
    {
        return toAjax(workUserMatterService.insert(workUserMatter));
    }


    /**
     * 删除用户收藏事项
     */
    @Log(title = "删除用户收藏事项", businessType = BusinessType.DELETE)
	@PostMapping("/remove")
    public AjaxResult remove(@RequestBody WorkUserMatter workUserMatter)
    {
        return toAjax(workUserMatterService.deleteByUserIdAndMatterId(workUserMatter));
    }
}
